home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_11_12 / pugh / nestarg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-10  |  521 b   |  24 lines

  1. Listing 1
  2.  
  3. //THE FOLLOWING TEMPLATE WORKS OK AS LONG AS IT'S NOT NESTED:
  4.  
  5. template <class X >
  6. struct SimpleVector
  7.     {
  8.     X *data;
  9.     SimpleVector(int len) : data(new X[len]) {}
  10.     ~SimpleVector() { delete [] data;}
  11.  
  12.     };
  13.  
  14. // NO WAY TO PROVIDE INNER SimpleVector CONSTRUCTOR WITH AN
  15. // ARGUMENT OF cols: 
  16.  
  17. template <class X >
  18. struct UnconstructableMatrix : 
  19.     public SimpleVector<SimpleVector<X>>
  20.     {
  21.     UnconstructableMatrix(int rows,int cols)    
  22.         : SimpleVector<SimpleVector<X>>(rows) {}
  23.     };
  24.